# -*- coding: utf-8 -*-
import json

def getPersonMainList(request):
    data_source_code = request.get("data_source_code")
    view_name = 'view_person_main_'+data_source_code
    request.set("view_name",view_name)

    #1数据
    request.cursor_standard.execute(request.formatSql('''
        select * 
        from middle.person_main_${data_source_code}
        where person_id like '%${person_id}%'
        limit ${start} , ${rows} 
    '''))
    rows = request.cursor_standard.fetchall()
    #2页码
    request.cursor_standard.execute(request.formatSql('''
        select count(*)  as total
        from middle.person_main_${data_source_code}
        where person_id like '%${person_id}%'
    '''))
    total = request.cursor_standard.fetchone()['total']
    return json.dumps({'rows':rows,'total':total}, ensure_ascii=False)